package commands;

import java.util.Hashtable;

import devices.Light;

import annotations.Command;
import annotations.Param;

@Command(name="Set light", description="Sets the light in the room to specified level and colour", id=0)
public class LightCommand implements CommandInterface{
	
	@Param(
			id=0,
			name="light",
			description="Overall light level",
			length=3,
			percentage=true
	)
	public int level;
	
	@Param(
			id=1,
			name="red",
			description="Red light level",
			length=3,
			percentage=true,
			mandatory=false
			
	)
	public int red;
	
	@Param(
			id=2,
			name="green",
			description="Green light level",
			length=3,
			percentage=true,
			mandatory=false
			
	)
	public int green;	
	
	@Param(
			id=3,
			name="blue",
			description="Blue light level",
			length=3,
			percentage=true,
			mandatory=false
			
	)
	public int blue;
	
	@Override
	public Object getInitialValueFor(Param p, Hashtable<Integer, Object> deviceData) {
		int paramId = p.id();
		
		switch (paramId){
			case 0: return deviceData.get(Light.LEVEL);
			case 1: return deviceData.get(Light.RED);
			case 2: return deviceData.get(Light.GREEN);
			case 3: return deviceData.get(Light.BLUE);
		}
		
		return null;
	}

}
